- gitlab_com = Gitlab.com?
- expanded = integration_expanded?('slack_app_')

= render ::Layouts::SettingsBlockComponent.new(s_('Integrations|GitLab for Slack app'),
  id: 'js-slack-settings',
  testid: 'slack-settings',
  expanded: expanded) do |c|
  - c.with_description do
    = s_('SlackIntegration|Configure your GitLab for Slack app.')
    = link_to(_('Learn more.'), help_page_path('administration/settings/slack_app.md'), target: '_blank', rel: 'noopener noreferrer')
  - c.with_body do
    - unless gitlab_com
      %h5
        = s_('SlackIntegration|Step 1: Create your GitLab for Slack app')
      %p
        = s_('SlackIntegration|You must do this step only once.')
      %p
        = render Pajamas::ButtonComponent.new(href: slack_app_manifest_share_admin_application_settings_path, target: '_blank') do
          = s_("SlackIntegration|Create Slack app")
      %hr
    %h5
      = s_('SlackIntegration|Step 2: Configure the app settings')
    %p
      - tag_pair_slack_apps = tag_pair(link_to('', 'https://api.slack.com/apps', target: '_blank', rel: 'noopener noreferrer'), :link_start, :link_end)
      - tag_pair_strong = tag_pair(tag.strong, :strong_open, :strong_close)
      = safe_format(s_('SlackIntegration|Copy the %{link_start}settings%{link_end} from %{strong_open}%{settings_heading}%{strong_close} in your GitLab for Slack app.'), tag_pair_slack_apps, tag_pair_strong, settings_heading: 'App Credentials')
      = link_to(_('Learn more.'), help_page_path('administration/settings/slack_app.md', anchor: 'configure-the-settings'), target: '_blank', rel: 'noopener noreferrer')
    = gitlab_ui_form_for @application_setting, url: general_admin_application_settings_path(anchor: 'js-slack-settings'), html: { class: 'fieldset-form' } do |f|
      = form_errors(@application_setting) if expanded
      %fieldset
        .form-group
          = f.gitlab_ui_checkbox_component :slack_app_enabled, s_('ApplicationSettings|Enable GitLab for Slack app')
        .form-group
          = f.label :slack_app_id, s_('SlackIntegration|Client ID'), class: 'label-bold'
          = f.text_field :slack_app_id, class: 'form-control gl-form-input'
        .form-group
          = f.label :slack_app_secret, s_('SlackIntegration|Client secret'), class: 'label-bold'
          = f.text_field :slack_app_secret, class: 'form-control gl-form-input'
          .form-text.gl-text-subtle
            = s_('SlackIntegration|Used for authenticating OAuth requests from the GitLab for Slack app.')
        .form-group
          = f.label :slack_app_signing_secret, s_('SlackIntegration|Signing secret'), class: 'label-bold'
          = f.text_field :slack_app_signing_secret, class: 'form-control gl-form-input'
          .form-text.gl-text-subtle
            = s_('SlackIntegration|Used for authenticating API requests from the GitLab for Slack app.')
        .form-group
          = f.label :slack_app_verification_token, s_('SlackIntegration|Verification token'), class: 'label-bold'
          = f.text_field :slack_app_verification_token, class: 'form-control gl-form-input'
          .form-text.gl-text-subtle
            = s_('SlackIntegration|Used only for authenticating slash commands from the GitLab for Slack app. This method of authentication is deprecated by Slack.')
      = f.submit _('Save changes'), pajamas_button: true

    - unless gitlab_com
      %hr
      %h5
        = s_('SlackIntegration|Update your Slack app')
      %p
        = s_('SlackIntegration|When GitLab releases new features for the GitLab for Slack app, you might have to manually update your copy to use the new features.')
        = link_to(_('Learn more.'), help_page_path('administration/settings/slack_app.md', anchor: 'update-the-gitlab-for-slack-app'), target: '_blank', rel: 'noopener noreferrer')
      %p
        = render Pajamas::ButtonComponent.new(href: slack_app_manifest_download_admin_application_settings_path, icon: 'download') do
          = s_("SlackIntegration|Download latest manifest file")
